Timer Class
A Timer is an object that can execute code after a specified period of time or at a repeated interval. If added to a window via the Window Editor, it is not visible in the built application since it is not a control.
More information available in parent classes: Object
Because it is subclassed from Object rather than RectControl, you can instantiate it via code with the New operator.
Notes
Although the Timer appears in the list of Built-in controls in the Window Editor, this is done only as a convenience to programmers. In terms of the object hierarchy, the Timer is not a control. This means you can create Timers in your code via the New operator, just as with other objects.
The Mode property controls the interval used to execute the Timer's Action event handler. If the Mode is not 0 (ModeOff), the Timer waits for the Period to pass before executing the Action event handler. If the Mode is set to ModeOff at Runtime, the Timer will immediately cease waiting and the Action event handler will no longer be executed.
The Timer will continue to execute its Action event handler (assuming the Mode property is not set to ModeOff) regardless of whether the window is frontmost or not. The visibility of the window also has no impact on the execution of a Timer's Action event handler. The Timer has been designed so that it yields time to other applications running on the computer so as not to bog down the machine.
Examples
The safest way to run the animation is to update it via a Timer. Add a Timer to the window that contains the SpriteSurface. Adjust its Period property according to how fast you want the animation to go and set its Mode to 2 (Multiple). In its Action event, call the SpriteSurface's Update method.
The Timer in the window calls the SpriteSurface's Update method in its Action event. It's mode is set to 2.
The same approach is recommended for animating RB3DSpace objects. With the Timer's Mode property set to 2, call the RB3DSpace's Update method from the Action event of a Timer object.
The following code in the Action event of a Timer detects whether the Up, Down, Left, or Right arrow keys are pressed.
StaticText1.text="left arrow key"
end if
If Keyboard.AsyncKeyDown(124) then
StaticText1.text="right arrow key"
end if
If Keyboard.AsyncKeyDown(125) then
StaticText1.text="down arrow key"
end if
If StaticText1.AsyncKeyDown(126) then
StaticText1.text="Up arrow key"
end if
See Also
Object class.